package com.sds.sweng.swat.miplatform.ui.design.parts.area;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.LineBorder;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.text.FlowPage;
import org.eclipse.draw2d.text.ParagraphTextLayout;
import org.eclipse.draw2d.text.TextFlow;
import org.eclipse.swt.SWT;

import com.sds.sweng.swat.miplatform.ui.design.layouts.EasyGridData;
import com.sds.sweng.swat.miplatform.ui.design.models.area.AreaTemplate;
import com.sds.sweng.swat.miplatform.ui.design.models.area.AreaTemplateTitle;
import com.sds.sweng.swat.miplatform.ui.design.parts.MiplatformComponentPart;

public class AreaTemplateTitlePart extends MiplatformComponentPart {

	public boolean isSelectable() {
		return false;
	}

	protected IFigure createFigure() {
		AreaTemplate parentModel = (AreaTemplate) getParent().getModel();

		FlowPage flowPage = new FlowPage();
		flowPage.setBackgroundColor(ColorConstants.lightBlue);
		flowPage.setBorder(new LineBorder());
		flowPage.setHorizontalAligment(PositionConstants.CENTER);
		flowPage.setOpaque(true);
		flowPage.setSize(AreaTemplateTitle.DEFAULT_WIDTH, 100);

		TextFlow textFlow = new TextFlow();
		textFlow.setText(parentModel.getAreaTitle());
		textFlow.setForegroundColor(ColorConstants.white);
		textFlow.setLayoutManager(new ParagraphTextLayout(textFlow,
				ParagraphTextLayout.WORD_WRAP_SOFT));

		flowPage.add(textFlow);

		getParentLayout().setConstraint(flowPage, EasyGridData.create(AreaTemplateTitle.DEFAULT_WIDTH, SWT.DEFAULT));

		return flowPage;
	}

	protected void createEditPolicies() {

	}

}
